pkg_name=binutils
version=2.25
build_dir=$builds_dir_root/$pkg_name-cross-$version
src_dir=$src_dir_root/$pkg_name-$version
url=http://ftpmirror.gnu.org/$pkg_name/$pkg_name-$version.tar.bz2

rm -Rf "$src_dir"
cd "$src_dir_root"
tar jxf "$pkg_name-$version.tar.bz2"

cd "$src_dir/bfd/doc"
cp "$builders_dir_root/$pkg_name/bfd-doc-Makefile.in.patch" ./Makefile.in.patch
patch -Ni ./Makefile.in.patch

rm -Rf "$build_dir"
mkdir -p "$build_dir"
cd "$build_dir"

export CFLAGS=-O0
"$src_dir/configure"				\
	"--build=$("$src_dir/config.guess")"	\
	--host=$gnu_target			\
	--target=$gnu_target			\
	--enable-serial-configure		\
	--prefix=/				\
	"--with-gmp=$sysroot"			\
	"--with-mpfr=$sysroot"			\
	"--with-mpc=$sysroot"			\
	--enable-host-shared			\
	--disable-multilib			\
	--disable-gold				\
	--disable-nls
unset CFLAGS

make

install_tmp_dir=/tmp/$pkg_name-cross-$version
rm -Rf "$install_tmp_dir"
mkdir -p "$install_tmp_dir"
make install "DESTDIR=$install_tmp_dir"

install_dirs_in_sysroot "$builders_dir_root/$pkg_name/runtime-cross.dirs" "$sysroot/"
install_files_in_sysroot "$builders_dir_root/$pkg_name/runtime-cross.files" "$install_tmp_dir/" "$sysroot/"
install_dirs_in_sysroot  "$builders_dir_root/$pkg_name/devel-cross.dirs" "$sysroot/"
install_files_in_sysroot "$builders_dir_root/$pkg_name/devel-cross.files" "$install_tmp_dir/" "$sysroot/"
elf_strip_in_sysroot "$builders_dir_root/$pkg_name/elf-strip-cross" "$sysroot/"

rm -Rf "$install_tmp_dir"
rm -Rf "$build_dir"
rm -Rf "$src_dir"
